home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1 / Ian and Stuart's One (Australia).iso / Australasian Legends / Commercial / Rainbow Hill / MacDOS™ 2.0.0 / batches / extractPath.bat < prev    next >
DOS Batch File  |  1994-06-30  |  1KB  |  53 lines

  1. @echo off
  2. !  extractPath.bat    Remove the a file or folder name from a full DOS path
  3. !
  4. !  extractPath path [varName]
  5. !
  6. !  where 'path' is the full path from which the item name is to be removed
  7. !  and 'varName' is a string containing the name of the global variable into
  8. !  which the resulting path is to be returned.
  9. !
  10. !  Note that no output variable is created if the parameter 'path' does not
  11. !  actually contain any path at all (ie. if it is the name of a local file or folder).
  12. !  Actually, the variable is removed if it already exists.
  13. !
  14. !  Copyright © 1994 by Rainbow Hill Pty Ltd. All rights reserved.
  15. !
  16.  
  17.     ! ensure that the first two parameters are there and that the third one is not
  18.     set doserr=13
  19.     if not "%3 " == " " goto ERR_LBL
  20.     if "%1 " == " " goto ERR_LBL
  21.     if "%2 " == " " goto ERR_LBL
  22.  
  23.     ! extract the name from the full path
  24.     set extractPath_name=%1
  25.     onerror SKIP_LBL
  26.     sstr/e/r extractPath_name "\"
  27. :SKIP_LBL
  28.     onerror SKIP2_LBL
  29.     sstr/e/r extractPath_name ":"
  30. :SKIP2_LBL
  31.  
  32.     ! check whether there is a path
  33.     if not "%extractPath_name%" == "%1" goto THERE_IS_LBL
  34.     set %2=
  35.     set doserr=0
  36.     goto DONE_LBL
  37.  
  38. :THERE_IS_LBL
  39.     ! copy the full path to a temporary variable and remove from it the name
  40.     set extractPath_path=%1
  41.     decr extractPath_path by "%extractPath_name%"
  42.     set %2=%extractPath_path%
  43.     set doserr=0
  44.     goto DONE_LBL
  45.  
  46. :ERR_LBL
  47.     show %doserr%
  48.  
  49. :DONE_LBL
  50.     ! remove the temporary variables
  51.     set extractPath_name=
  52.     set extractPath_path=
  53.